fix(backend): unbreak main — ws-b lifecycle tests rotted when the wall clock passed their pinned NOW + TTL#10169
Conversation
tests/unit/test_ws_b_short_term_lifecycle.py pinned
NOW = datetime(2026, 6, 20, 12, 0, tzinfo=timezone.utc)
Seven of its cases persist an item with write_canonical_extraction_memory,
which takes no clock parameter and stamps captured_at from the real clock, and
then drive processing with now=NOW. The processed patch sets
expires_at = default_short_term_expiry(now) # now + DEFAULT_SHORT_TERM_TTL_DAYS (30)
so expires_at was fixed at 2026-06-20 + 30d = 2026-07-20 while captured_at
tracked real time. MemoryItem.validate_tier_invariants requires
short_term expires_at must be after captured_at
which held until the wall clock passed 2026-07-20 and then stopped holding. The
suite began failing on its own, with no code change, and every Backend Unit
Tests run on main has been red since:
FAILED test_required_processing_receipt_unlocks_durable_promotion
FAILED test_required_processing_receipt_is_bound_to_current_content_and_revision
FAILED test_required_processor_retry_rebases_operation_after_unrelated_head_advance
FAILED test_inflight_promotion_cannot_overwrite_negative_user_review
FAILED test_required_promotion_merges_exact_existing_long_term
FAILED test_required_promotion_merges_multiple_sources_in_same_run
FAILED test_required_promotion_retry_after_supersede_failure_is_idempotent_across_run_ids
all with error_code='ValidationError' from that invariant.
Fix: anchor NOW to the real clock (today at 12:00 UTC) so the injected clock
and the real captured_at can never drift apart by more than the TTL. NOW stays
a single fixed value for the whole run, so the tests remain deterministic; it
simply no longer rots.
The production behaviour is not at fault here — the mismatch is between the
test's injected clock and the un-injectable one inside
write_canonical_extraction_memory, so this is a test-only change.
Note: five other unit files pin the same 2026-06-20 date
(test_canonical_consolidation, test_canonical_maintenance_ordering,
test_canonical_consolidation_apply, test_canonical_kg_promotion,
test_v3_canary_approval_artifact). They pass today because none of them mixes a
real-clock write with a TTL computed off NOW, but they carry the same latent
shape and are worth the same treatment if they ever start failing.
Verification: 25 pass on this file; restoring the fixed date reproduces exactly
the 7 failures CI reports on main.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks @arhxam — clean, well-documented fix for a genuine time-bomb in the suite. Your diagnosis is correct: the tests pinned The directly relevant Backend unit suite check passes on this head. (Hygiene/Formatting show as cancelled, which looks like the expected path-filter behavior for a backend-only test change — worth a maintainer confirming the branch-protection view is green before merge.) Optional follow-up (not blocking): the deeper root cause is that Leaving a positive signal rather than a formal approval. Appreciate the quick unblock of by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Backend fix that UN-BREAKS main: ws_b lifecycle tests rotted when wall clock passed pinned NOW+TTL — approve only; DIRTY, needs rebase by author to land and green main
mainis currently red, and this is whyEvery recent Backend Unit Tests run on
mainfails with the same 7 failures intests/unit/test_ws_b_short_term_lifecycle.py. No code change caused it — the suite rotted on a date.The file pins:
Seven cases persist an item with
write_canonical_extraction_memory, which takes no clock parameter and stampscaptured_atfrom the real clock, then drive processing withnow=NOW. The processed patch sets:So
expires_atwas frozen at2026-06-20 + 30d = 2026-07-20, whilecaptured_attracked real time.MemoryItem.validate_tier_invariantsrequires:That held until the wall clock passed 2026-07-20 — and then stopped.
Observed directly:
All seven failures surface as
error_code='ValidationError':Fix
Anchor
NOWto the real clock (today at 12:00 UTC) so the injected clock and the realcaptured_atcan never drift apart by more than the TTL:NOWremains a single fixed value for the whole run, so the tests stay deterministic — it simply no longer rots.Test-only change. The production behaviour isn't at fault: the mismatch is between the test's injected clock and the un-injectable one inside
write_canonical_extraction_memory. Giving that function anowparameter would be the deeper fix, but it changes a production signature to serve a test, so I've left it — happy to do it that way if you'd prefer.Verification
Heads-up on the same shape elsewhere
Five other unit files pin the same
2026-06-20date —test_canonical_consolidation,test_canonical_maintenance_ordering,test_canonical_consolidation_apply,test_canonical_kg_promotion,test_v3_canary_approval_artifact. They pass today because none mixes a real-clock write with a TTL computed offNOW, but they carry the same latent shape. I've left them alone rather than widen this PR.Failure class
Failure-Class: none
A test clock that goes stale against a real-clock write; no registered class covers it.